﻿@page "/"
@inject DDnsConfiguration Configuration
@inject DnsPodRecord Record

@using System.Text.RegularExpressions
@using System.Net

<h2>你的公网IP</h2>

<hr />

<h2>你的vicp公网IP：@GetDDNSIP()</h2>

@code {
    private const string MyDDNS = "lishewen.vicp.net";
    private static async Task<string> GetIPAsync()
    {
        HttpClient client = new HttpClient();

        string all = string.Empty;

        var res = await client.GetAsync("http://pv.sohu.com/cityjson?ie=utf-8");
        if (res.IsSuccessStatusCode)
            all = await res.Content.ReadAsStringAsync();

        Match rebool = Regex.Match(all, @"\d{2,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");
        return rebool.Value;
    }

    private string GetDDNSIP()
    {
        IPHostEntry IPinfo = Dns.GetHostEntry(MyDDNS);
        return IPinfo.AddressList[0].ToString();
    }
}